package com.knowledge.share.service.impl;

import com.knowledge.share.mapper.MemberMapper;
import com.knowledge.share.pojo.Member;
import com.knowledge.share.service.MemberService;
import com.knowledge.share.utils.EncryptUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Slf4j
@Service
public class MemberServiceImpl implements MemberService {

    @Autowired
    private MemberMapper memberMapper;
    /**
     * @desc 创建用户信息
     * @param member
     */
    @Override
    public void createUser(Member member) {

        member.setGender((short) 1);
        member.setStatus((short) 1);
        member.setCreateTime(LocalDateTime.now());
        member.setUpdateTime(LocalDateTime.now());
        memberMapper.createMember(member);
    }

    /**
     * @desc 通过用户名获取对象信息
     * @param username
     * @return
     */
    @Override
    public Member getUserByAccount(String username) {
        Member user = memberMapper.getUserByAccount(username);
        return user;
    }

    /**
     * @desc 通过id查询用户是否存在
     * @param id
     * @return
     */
    @Override
    public Member getUserById(Integer id) {
        Member user = memberMapper.getUserById(id);
        return user;
    }

    @Override
    public void updateInfo(Member member) {
        memberMapper.updateInfo(member);
    }
}
